﻿<%@ Page Language="C#" AutoEventWireup="true" CodeFile="WyUserIdGenerate.aspx.cs"
    Inherits="GenerateCode_WyUserIdGenerate" %>

<%@ Import Namespace="WF_Business" %>
<%@ Import Namespace="System.Data" %>
<html>
<head runat="server">
    <title>注册用户通过审核</title>
    <link href="../css/page.css" rel="stylesheet" type="text/css" />
</head>
<script type="text/javascript">
    function tosubmit(page) {
        var strUrl = "WyUserIdGenerate.aspx";
        if (page == "" || page == null)
            strUrl += "?pagenow=" + document.all.jumpPage.value
        else
            strUrl += "?pagenow=" + page;

        strUrl += '&flag=<%=Request.Params["flag"]%>'

        window.location.href = strUrl;
    }

    function SubmitClient(paramId, paramResult) {
        if (confirm('确定执行此操作?')) {
            var url = "UserInfoSpResult.aspx?sid=" + paramId + "&resultFlag=" + paramResult;
            this.location = url;
        }
    }

    function query() {
        var paramId = document.getElementById("txtSeach").value;
        var url = "WyUserIdGenerate.aspx?flag=query&username=" + paramId;
        this.location = url;
    }

    function keyEvent() {
        if (event.keyCode == 13) {
            //tab健转换焦点
            event.keyCode = 9;
            event.returnValue = false;
            query();
        }
    }

    //设置tabcontrol按钮的背景颜色
    function SetBackColor(varCtrl) {
        if (varCtrl == "0") {
            document.getElementById("td1").style.backgroundImage = "url(../images/top_button_03.gif)";
            document.getElementById("td2").style.backgroundImage = "url(../images/top_button_05.gif)";
        }
        else {
            document.getElementById("td1").style.backgroundImage = "url(../images/top_button_05.gif)";
            document.getElementById("td2").style.backgroundImage = "url(../images/top_button_03.gif)";
        }
    }

    //查询用户详细 addby zhongjian 20091204
    function UserMessage(id) {
        var url = "../WebPubManager/UserMassage.aspx?id=" + id;
        window.open(url, "view", "top=20,left=20,toolbar=no,menubar=no,scrollbars=yes,location=no,status=no,width=500,height=550;");
    }   
	
</script>
<body>
    <form id="form1" runat="server">
    <br>
    <table border="0">
        <tr>
            <td id="td1" runat="server" style="background-image: url(../images/top_button_05.gif);
                background-repeat: no-repeat; text-align: center; height: 35px; width: 93px;">
                <a href="WyUserIdGenerate.aspx?flag=nosp">未审批</a>
            </td>
            <td id="td2" runat="server" style="background-image: url(../images/top_button_03.gif);
                background-repeat: no-repeat; text-align: center; height: 35px; width: 93px;">
                <a href="WyUserIdGenerate.aspx?flag=ysp">已审批</a>
            </td>
            <td style="width: 200px; text-align: right;">
                中文用户名查询：
            </td>
            <td style="text-align: center;">
                <input type="text" id="txtSeach" onkeydown="keyEvent()" />
            </td>
            <td>
                <input type="button" class="NewButton" value="查询" name="btnQuery" onclick="query()">
            </td>
        </tr>
    </table>
    <table width="100%" border="0" align="center">
        <tr>
            <td>
                <div class="tab_middle">
                    <table width="100%" border="0" align="center" cellpadding="0" cellspacing="0" class="tab">
                        <tr>
                            <th>
                                用户id
                            </th>
                            <th>
                                用户名称
                            </th>
                            <th>
                                手机号
                            </th>
                            <th>
                                所属企业名称
                            </th>
                            <th>
                                注册时间
                            </th>
                            <th>
                                操作
                            </th>
                        </tr>
                        <%	
                            //定义分页变量
                            int pagesize = 15;//页面记录数
                            int pagenow = 1;//当前页
                            int pagecount = 0;//总页数

                            string mpage = Request["pagenow"];

                            ExtBusiness.Controls.Pager mypage = null;

                            if (!string.IsNullOrEmpty(mpage))
                            {
                                pagenow = System.Int32.Parse(mpage); ;
                                if (pagenow < 1)
                                    pagenow = 1;
                            }

                            string sql = string.Empty;
                            DataTable rs1;

                            string strFlag = string.Empty;

                            if (Request.Params["flag"] != null)
                            {
                                strFlag = Request.Params["flag"];
                            }

                            if (strFlag.CompareTo("ysp") == 0)//查看审批通过的用户
                            {
                                Page.ClientScript.RegisterStartupScript(this.GetType(), "function", "<script>SetBackColor(0);</script>");//设置按钮样式

                                sql = @"select s.id, userid, USERNAME, mobile,(select UNITSNAME from sys_units a where a.id=UNITSID) unitname, ISVALID,to_char(CREATEDATE,'yyyy-mm-dd hh24:mi') txtcreatedate from sys_user s where ISVALID =1 order by createdate desc,userid";
                            }
                            else if (strFlag.CompareTo("query") == 0)//查询标志
                            {
                                string strQueryUserName = Request["username"];

                                sql = @"select s.id, userid, USERNAME, mobile,(select UNITSNAME from sys_units a where a.id=UNITSID) unitname, ISVALID,to_char(CREATEDATE,'yyyy-mm-dd hh24:mi') txtcreatedate from sys_user s where 1=1";
                                if (!string.IsNullOrEmpty(strQueryUserName))
                                {
                                    sql += string.Format(" and USERNAME like '%{0}%'", strQueryUserName);
                                }

                                sql += " order by createdate desc,userid";
                            }
                            else//默认
                            {
                                sql = @"select s.id, userid, USERNAME, mobile,(select UNITSNAME from sys_units a where a.id=UNITSID) unitname, ISVALID,to_char(CREATEDATE,'yyyy-mm-dd hh24:mi') txtcreatedate from sys_user s where ISVALID=0 or ISVALID is null order by createdate desc,userid";
                            }

                            try
                            {
                                SysParams.OAConnection().RunSql(sql, out rs1);
                                mypage = new ExtBusiness.Controls.Pager(rs1, pagenow, pagesize);
                                pagecount = mypage.PageCount;
                                System.Collections.Generic.List<System.Data.DataRow> listwork = mypage.CurrentPageList;

                                for (int i = 0; i < listwork.Count; i++)
                                {
                                    //新增查看用户信息
                                    string UserMessage = "";//用户信息
                                    System.Data.DataRow myArray = listwork[i];
                                    UserMessage = string.Format("<a href='#' onclick=\"UserMessage('{0}')\">{1}</a>", myArray["userid"], myArray["userid"]);
                                    Response.Write("<tr bgcolor=\"#ffffff\" onmouseover=\"this.style.backgroundColor='#caf7fd'\" onMouseOut=\"this.style.backgroundColor='#ffffff'\">\r\n");

                                    Response.Write("<td align=\"center\">" + UserMessage + "</td>\r\n");
                                    Response.Write("<td align=\"center\">" + myArray["USERNAME"] + "</td>\r\n");
                                    Response.Write("<td align=\"center\">" + myArray["mobile"] + "</td>\r\n");
                                    Response.Write("<td align=\"center\">" + myArray["unitname"] + "</td>\r\n");
                                    Response.Write("<td align=\"center\">" + myArray["txtcreatedate"] + "</td>\r\n");

                                    string strUserFlag = myArray["ISVALID"].ToString();

                                    if (strFlag.CompareTo("ysp") == 0)//查询已审批
                                    {
                                        Response.Write("<td style='background-color:Green'>已通过</td>\r\n");
                                    }
                                    else if (strFlag.CompareTo("query") == 0)//查询标志
                                    {
                                        if (!string.IsNullOrEmpty(strUserFlag))
                                        {
                                            if (strUserFlag.CompareTo("1") == 0)
                                            {
                                                Response.Write("<td  style='background-color:Green'>已通过</td>\r\n");
                                            }
                                            else
                                            {
                                                Response.Write("<td  style='background-color:red'>未通过</td>\r\n");
                                            }
                                        }
                                        else
                                        {
                                            Response.Write("<td ><a href='#' onclick='SubmitClient(\"" + myArray[0] + "\",1)'>允许通过</a>&nbsp;&nbsp;&nbsp;&nbsp;<a href='#' onclick='SubmitClient(\"" + myArray[0] + "\",0)'>删除</a></td>\r\n");
                                        }
                                    }
                                    else//默认
                                    {
                                        Response.Write("<td ><a href='#' onclick='SubmitClient(\"" + myArray[0] + "\",1)'>允许通过</a>&nbsp;&nbsp;&nbsp;&nbsp;<a href='#' onclick='SubmitClient(\"" + myArray[0] + "\",0)'>删除</a></td>\r\n");
                                    }

                                    Response.Write("</tr>" + "\r\n");
                                }
                            }
                            catch (System.Exception e)
                            {
                                Common.WindowAppear.WriteAlert(Page, e.Message);
                            }
	
	
                        %>
                    </table>
                    <table width="100%" border="0" cellspacing="0" cellpadding="4">
                        <tr>
                            <td align="right" colspan="8" height="20">
                                每页<%=pagesize%>行 共<%=mypage.RecordCount %>行 当前第<%=pagenow%>页 共<%=pagecount %>页
                                <%
                                    if (pagenow == 1)
                                    {
                                        Response.Write(" 首页 上一页");
                                    }
                                    else
                                    {
		
                                %>
                                <a href="javascript:tosubmit('1')">首页</a> <a href="javascript:tosubmit('<%=pagenow - 1%>')">
                                    上一页</a>
                                <%
                                    }
	
                                %>
                                <%
                                    if (pagenow == pagecount)
                                    {
                                        Response.Write("下一页 尾页");
                                    }
                                    else
                                    {
		
                                %>
                                <a href="javascript:tosubmit('<%=pagenow + 1%>')">下一页</a> <a href="javascript:tosubmit('<%=pagecount%>')">
                                    尾页</a>
                                <%
                                    }
	
                                %>
                                转到第<select name="jumpPage" id="jumpPage" onchange="tosubmit()">
                                    <%
                                        for (int i = 1; i <= pagecount; i++)
                                        {
                                            if (i == pagenow)
                                            {
			
                                    %>
                                    <option selected value="<%=i%>">
                                        <%=i%></option>
                                    <%
                                            }
                                            else
                                            {
			
                                    %>
                                    <option value="<%=i%>">
                                        <%=i%></option>
                                    <%
                                            }
                                        }
	
                                    %>
                                </select>
                            页
                        </tr>
                    </table>
                </div>
            </td>
        </tr>
    </table>
    </form>
</body>
</html>
